<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: snow_header"></head>
<style>
	.yesnoData-success {
		color: #fff;
		background: #5cb85c;
	}
	.yesnoData-default {
		color: #000;
		background: #eeeeee;
	}
	</style>
<!--<style type="text/css">-->
	<!--table {-->
		<!--/*为表格设置合并边框模型*/-->
		<!--border-collapse: collapse;-->
		<!--/*列宽由表格宽度和列宽度设定*/-->
		<!--table-layout: fixed;-->
	<!--}-->

	<!--td {-->
		<!--border: 1px solid #ddd;-->
		<!--/*允许在单词内换行。*/-->
		<!--word-break: break-word;-->

	<!--}-->
<!--</style>-->

<body class="gray-bg">
    <div class="container-div">
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-success btn-rounded" onclick="bootstrapTable.operateAdd()" shiro:hasPermission="module:domain:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="bootstrapTable.operateRemoveAll()" shiro:hasPermission="module:domain:remove">
				<i class="fa fa-trash-o"></i> 删除
			</a>
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"  data-mobile-responsive="true" style="white-space:nowrap"></table>
		</div>
    </div>
    <div th:include="include :: snow_footer"></div>
    <script th:inline="javascript">
		var addFlag= [[${@permission.hasPermi('module:domain:add')}]];
        var editFlag = [[${@permission.hasPermi('module:domain:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:domain:remove')}]];
        var prefix = ctx + "module/domain";
        var yesnoDatas = [{"dictLabel":"√","dictValue":"1","listClass":"success"},
            {"dictLabel":"×","dictValue":"0","listClass":"default"}];

		var bootstrapTable=$.snowBootstrap.init("bootstrap-table");
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
				copyUrl: prefix + "/copy/{id}",
                removeUrl: prefix + "/remove",
                modalName: "域名管理",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'apiDomainId', 
					title : '域名ID'
				},
				{
					field : 'named', 
					title : 'URL域名'
				},
				{
					field : 'port', 
					title : '端口'

				},
				{
					field : 'description', 
					title : '描述' 
				},
				{
					field : 'ipv4', 
					title : '实际ip地址' 
				},
				{
					field : 'ipv4port', 
					title : '实际端口' 
				},
				{
					field : 'opened',
					title : '对外接口',
                    formatter: function(value, row, index) {
                        var actions = [];
                        $.each(yesnoDatas, function(index, dict) {
                            if (dict.dictValue == value) {
                                actions.push("<span class='badge yesnoData-" + dict.listClass + "'>" + dict.dictLabel + "</span>");
                                return false;
                            }
                        });
                        return actions.join('');
                    }
				},
				{
					field : 'url', 
					title : '访问地址' ,
                    formatter: function(value,row,index){
                        if(row.posturl ==undefined){
                            return value;
                        }
                        return "<a href='"+row.posturl+"' target='_blank'>"+value+"</a>";
                    }
				},
				// {
				// 	field : 'posturl',
				// 	title : 'post直接访问地址' ,
				// 	formatter: function(value,row,index){
				// 	    if(value ==undefined){
                //             return "";
				// 		}
                //         return "<a href='"+value+"' target='_blank'>"+value+"</a>";
				// 	}
				// },
				{
					field : 'remark',
					title : '备注'
				},
				{
					field : 'createBy',
					title : '创建者'
				},
				{
					field : 'createTime',
					title : '创建时间',
					width : 200

				},
				{
					field : 'updateBy',
					title : '更新者'
				},
				{
					field : 'updateTime',
					title : '更新时间'
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="bootstrapTable.operateEdit(\'' + row.apiDomainId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-warning btn-xs ' + addFlag + '" href="#" onclick="bootstrapTable.operateCopy(\'' + row.apiDomainId + '\')"><i class="fa fa-copy"></i>复制</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="bootstrapTable.operateRemove(\'' + row.apiDomainId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
			bootstrapTable.tableInit(options);
            // $.table.init(options);
        });
    </script>
</body>
</html>